# https://leetcode.cn/problems/combination-sum-iv/description/

class Solution:
    def combinationSum4(self, nums: List[int], target: int) -> int:
        # f[i]: 总和为 i 时的方案数
        # 转移 f[i] = f[i] + f[i - x]
        f = [0] * (target + 10)
        f[0] = 1
        for i in range(0, target + 1) :
            for xx in nums :
                if i >= xx :
                    f[i] = f[i] + f[i - xx]
        return f[target]